package thecardgame;

import java.util.ArrayList;
import java.util.List;

public class Test {
    public static void main(String[] args) {
        Game game = new Game();
        List<Card> cardList = game.createCards();
        System.out.println("初始牌：" + cardList);

        game.shuffle(cardList);
        System.out.println("洗过的牌：" + cardList);

        List<List<Card>> hand = game.play(cardList);
        for (int i = 0; i < hand.size(); i++) {
            System.out.println("第" + (i+1) + "个人的牌是：" + hand.get(i));
        }

        System.out.println("剩下的牌为：" + cardList);
    }

    public List<List<Integer>> yangHuiTriangle(int numRows) {
        List<List<Integer>> ret = new ArrayList<>();
        List<Integer> list0 = new ArrayList<>();
        //第一行
        list0.add(1);
        ret.add(list0);
        //从第二行开始
        for (int i = 1; i < numRows; i++) {
            //创建当前行
            List<Integer> tmpList = new ArrayList<>();
            //每一行的第一个元素
            tmpList.add(1);
            //上一行的list
            List<Integer> prevRow = ret.get(i - 1);
            //计算当前行的中间值
            for (int j = 1; j < i; j++) {
                int val1 = prevRow.get(j);
                int val2 = prevRow.get(j - 1);
                tmpList.add(val1 + val2);
            }
            //每一行的最后一个元素
            tmpList.add(1);
            ret.add(tmpList);
        }
        return ret;
    }

    public static void main1(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();
        list.add(3);
        list.add(2);
        System.out.println(list);

        ArrayList<Integer> tmpList = new ArrayList<>(list);
        tmpList.add(88);//添加元素到list之后
        tmpList.add(99);
        System.out.println(tmpList);
    }
}
